use MainFile_PR
replace ParFarmland=ParFarmland/100000
generate ParFarmlandSq=ParFarmland^2
xtset YearMarrD5


local keyx AgeMarried 
local keyx1 BroAtMarr SisAtMarr ParFarmland ParFarmlandSq
local xcontrols Age AgeSq FaAge YearsEd Muslim BirthOrder MoAlFstMarr FaAlFstMarr  MoEverAttd FaEverAttd RainDevYearWom11 RainDevYearWom12 RainDevYearWom13 
local conditions "Female==1 & Age~=. & AgeSq~=. & YearsEd~=. & Muslim~=. & BirthOrder~=. & BroAtMarr~=. & RainDevYearWom11~=. &  Dowry~=. & FaAge~=."


xi: regress MarrCousin `keyx' `keyx1' i.YearMarrD5 if `conditions',  cluster(bari_num)
est2vec AgeMarriedRegs, e(N r2) replace vars(AgeMarried BroAtMarr SisAtMarr ParFarmland ParFarmlandSq Age AgeSq FaAge YearsEd Muslim MoAlFstMarr FaAlFstMarr BirthOrder MoEverAttd FaEverAttd RainDevYearWom11 RainDevYearWom12 RainDevYearWom13) 
test ParFarmland ParFarmlandSq

rename MarrCousin MarrCousin2
xi: regress MarrCousin2 `keyx' `keyx1' `xcontrols' i.YearMarrD5 if `conditions',  cluster(bari_num)
test ParFarmland ParFarmlandSq
est2vec AgeMarriedRegs, addto(AgeMarriedRegs)


/*******************************************************************************************************************/
/*******************************************************************************************************************/
/*******************************************************************************************************************/
/*******************************************************************************************************************/


clear
use MainFile_PR
replace ParFarmland=ParFarmland/100000
generate ParFarmlandSq=ParFarmland^2

lab var AgeMarried "Age at marriage"
lab var ParFarmland "Parents farmland"
lab var ParFarmlandSq "Parents farmland squared"
lab var AgeSq "Age squared"
lab var FaAge "Father's age"
lab var BirthOrder "Birth order"
lab var YearsEd "Years of schooling"
lab var MoAlFstMarr "Mother alive at marriage" 
lab var FaAlFstMarr "Father alive at marriage"
lab var BroAtMarr "Brothers at marriage"
lab var SisAtMarr "Sisters at marriage"
lab var MoEverAttd "Mother attended school"
lab var FaEverAttd "Father attended school"
lab var RainDevYearWom10 "Rainfall dev when woman age 10"
lab var RainDevYearWom11 "Rainfall dev when woman age 11"
lab var RainDevYearWom12 "Rainfall dev when woman age 12"
lab var RainDevYearWom13 "Rainfall dev when woman age 13"
lab var RainDevYearWom14 "Rainfall dev when woman age 14"
lab var RainDevYearWom15 "Rainfall dev when woman age 15"

/* drop missing observations */
drop if AgeMarried==.

local keyx AgeMarried 
local keyx1 BroAtMarr SisAtMarr ParFarmland ParFarmlandSq 
local xcontrols Age AgeSq FaAge YearsEd Muslim BirthOrder MoAlFstMarr FaAlFstMarr MoEverAttd FaEverAttd RainDevYearWom11 RainDevYearWom12 RainDevYearWom13
local conditions "Female==1 & Age~=. & AgeSq~=. & YearsEd~=. & Muslim~=. & BirthOrder~=. & BroAtMarr~=. & RainDevYearWom11~=. & RainDevYearWom12~=. & RainDevYearWom13~=. & FaAlFstMarr~=. & MarrCousin~=. & FaAge~=."

/**** assume that missing responses for farmland and 0's *****/

xi: regress Dowry `keyx' `keyx1' i.YearMarrD5 if `conditions'
test ParFarmland ParFarmlandSq
est2vec AgeMarriedRegs, addto(AgeMarriedRegs)

rename Dowry Dowry2
xi: regress Dowry2 `keyx' `keyx1' `xcontrols' i.YearMarrD5 if `conditions'
test ParFarmland ParFarmlandSq
est2vec AgeMarriedRegs, addto(AgeMarriedRegs)


/**** assume that missing responses for farmland and 0's *****/

xi: regress LDowryVal `keyx' `keyx1' i.YearMarrD5 if `conditions'
test ParFarmland ParFarmlandSq
est2vec AgeMarriedRegs, addto(AgeMarriedRegs)

rename LDowryVal LDowryVal2
xi: regress LDowryVal2 `keyx' `keyx1' `xcontrols' i.YearMarrD5 if `conditions'
test ParFarmland ParFarmlandSq
est2vec AgeMarriedRegs, addto(AgeMarriedRegs)

est2tex AgeMarriedRegs, replace dropall mark(stars) fancy digits(4) label



